package myJs.myPkg

import myJs.myPkg.jsext._

import scala.scalajs.js

import scala.scalajs.js.Dynamic.{global => g}
import scala.scalajs.js.annotation.{JSGlobal, JSImport, JSName}

/**
 * Created by yz on 2019/3/14
 */
object Swal {

  @js.native
  @JSGlobal("swal")
  def swal(options: SwalOptions):Unit = js.native

  @js.native
  @JSGlobal("swal")
  def swal(options: SwalOptions, f: js.Function):Unit = js.native

  @js.native
  @JSGlobal("close")
  def close() = js.native

}

object SwalOptions extends SwalOptionsBuilder(noOpts)

class SwalOptionsBuilder(val dict: OptMap) extends JSOptionBuilder[SwalOptions, SwalOptionsBuilder](new SwalOptionsBuilder(_)) {

  def text(v: js.Any) = jsOpt("text", v)

  def title(v: String) = jsOpt("title", v)

  def `type`(v: String) = jsOpt("type", v)

  def showCancelButton(v: Boolean) = jsOpt("showCancelButton", v)

  def showConfirmButton(v: Boolean) = jsOpt("showConfirmButton", v)

  def confirmButtonClass(v: String) = jsOpt("confirmButtonClass", v)

  def confirmButtonText(v: String) = jsOpt("confirmButtonText", v)

  def closeOnConfirm(v: Boolean) = jsOpt("closeOnConfirm", v)

  def cancelButtonText(v: String) = jsOpt("cancelButtonText", v)

  def cancelButtonClass(v: String) = jsOpt("cancelButtonClass", v)

  def showLoaderOnConfirm(v: Boolean) = jsOpt("showLoaderOnConfirm", v)

}

trait SwalOptions extends js.Object {

}

@js.native
@JSImport("bootstrap-sweetalert", JSImport.Namespace)
object BootstrapSweetalertLib extends js.Object